<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
  <head>
	<meta charset="utf-8">
    <title>dendrogram</title>
	<script src="../js/d3.v3.min.js"></script>

  <link rel="stylesheet" href="../dendrogram/css/d3.dendrogram.css" type="text/css"></link>
 
<style>
#chartPanel {
	float: left; 
}
#controlPanel { 
	position: absolute;
	right: 10px;
	top: 10px;
	width: 100px;
}
.legend {
	font-size: 20px;
} 
</style>
  <s:head/>
  </head>

  <body>
  
  <div id="chartPanel"></div>
  <div id="controlPanel">
  	
  	<form action="<s:url action="fileUpload" namespace="/dendrogram"/>" method="post" enctype="multipart/form-data">
  		<input type="hidden" name="destPage" value="<%= request.getServletPath()%>" />
  		<div>
  			<label for="dataFile">data file</label>
  			<s:file name="data" />
  		</div>
  		<div>
  			<input type="submit"/>
  		</div>
  	</form>
  </div>
  
<script>
var width = 960,
height = 2200;

var cluster = d3.layout.cluster()
.size([height, width - 160]);

var diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.y, d.x]; });

var svg = d3.select("#chartPanel").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(40,0)");

d3.json('<s:property value="#session['CURRENT_FILE']"/>', function(error, root) {
var nodes = cluster.nodes(root),
  links = cluster.links(nodes);

var link = svg.selectAll(".link")
  .data(links)
.enter().append("path")
  .attr("class", "link")
  .attr("d", diagonal);

var node = svg.selectAll(".node")
  .data(nodes)
.enter().append("g")
  .attr("class", "node")
  .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })

node.append("circle")
  .attr("r", 4.5);

node.append("text")
  .attr("dx", function(d) { return d.children ? -8 : 8; })
  .attr("dy", 3)
  .style("text-anchor", function(d) { return d.children ? "end" : "start"; })
  .text(function(d) { return d.name; });
});

d3.select(self.frameElement).style("height", height + "px");
</script>
  
  
  </body>
</html>



















